草庐IT

java - 在 Java 中连接到 MongoDB

全部标签

go - 异常大量的 TCP 连接超时错误

我正在使用GoTCP客户端连接到我们的GoTCP服务器。我能够连接到服务器并正确运行命令,但是在尝试连接到我们的TCP服务器或发送消息时,我的TCP客户端经常会报告异常大量的连续TCP连接错误一旦连接:dialtcpkubernetes_node_ip:exposed_kubernetes_port:connectex:Aconnectionattemptfailedbecausetheconnectedpartydidnotproperlyrespondafteraperiodoftime,orestablishedconnectionfailedbecauseconnectedho

mongodb - UUID 作为 _id 错误 - 不能将数组用于 _id

我正在尝试为MongoDB中的_id字段使用UUID。我有一个包装器结构来保存我的记录,如下所示:typemongoWrapperstruct{IDuuid.UUID`bson:"_id"json:"_id"`Paymentstorage.Payment`bson:"payment"json:"payment"`}这是我围绕MongoDB驱动程序包中的InsertOne函数编写的代码:func(s*Storage)Create(newPaymentstorage.Payment)(uuid.UUID,error){mongoInsert:=wrap(newPayment)c:=s.cl

mongodb - 如何根据带有整数键的嵌套数组中的值查找文档?

我的查找查询如下所示:bson.M{"_id":oId,"items":bson.M{"$elemMatch":bson.M{"id":theId,"active":true}}}(其中theId是方法中的对象ID)我要做的是选择一个具有匹配id且active设置为true的文档{"_id":ObjectId("5ca0e44acb216df65405dc5f"),"items":{"0":{"id":ObjectId("5c9fbb25e86deef65491c321"),"active":true},"1":{"id":ObjectId("5c9fbb57cb216df65405d

go - 为什么客户端通过 http.ServeContent 阅读我的视频时一直关闭连接?

我目前正在做一个小项目,通过http.ServeContent向浏览器或其他媒体客户端提供视频服务。我已经实现了自己的ReadSeeker,如下所示://theseekisnotfullyworkingyetbutworksfinefortheinitialtwocallsthatisbeingcalledinternallyfromhttptodecidethefilesize.func(c*Client)Seek(offsetint64,whenceint)(tint64,eerror){switchwhence{case0:t=offsetcase1:t=c.seek+offse

mongodb - 为什么我的 mongodb 查询返回 0 个结果?

这是我的数据库集合:使用此go代码,我尝试获取所有参与故事或使用给定ID创建故事的用户。funcmain(){forstf.DB==nil{}collection:=stf.DB.Collection("user")ctx,cancel:=context.WithTimeout(context.Background(),30*time.Second)defercancel()id,_:=primitive.ObjectIDFromHex("5cb4dd7e29d3dca573a73d4c")fter:=bson.M{"_id":id}involvedFilter:=bson.M{"st

go - 在本地使用 k8s go-client 连接到集群

我想运行GoK8S客户端库并使用我本地定义的kubeconfig连接到集群mac下/Users/i0334456/.kube/config错误是:#k8s-go-client/vendor/k8s.io/client-go/restvendor/k8s.io/client-go/rest/request.go:598:31:notenoughargumentsincalltowatch.NewStreamWatcherhave(*versioned.Decoder)want(watch.Decoder,watch.Reporter)这是我尝试使用的程序packagemainimport

postgresql - 连接 : connection timed out

我已经使用gosql包成功连接到Postgres数据库:...db,err:=sql.Open("postgres",connStr)然后我使用返回的数据库执行(长时间运行的)查询:rows,err:=db.Query(...)我得到了错误:dialtcpxx.xxx.xxx.xx:5432:connect:connectiontimedout我有几个问题:为什么连接超时?我能做些什么来防止它超时吗? 最佳答案 sql.Open()mayjustvalidateitsargumentswithoutcreatingaconnecti

go - 无法通过网络连接到 VoltDB

我开始使用VoltDB。在LAN中的服务器上运行VoltDB社区。服务器启动后报告服务器初始化完成Build:9.0voltdb-9.0-0-g6aae38a-localCommunityEditionLoadednode-specificsettingsfromvoltdbroot/config/path.propertiesConnectingtoVoltDBclusterastheleader...Hostidofthisnodeis:0RestartingthedatabaseclusterfromthecommandlogsWARN:Userauthenticationisn

mongodb - 如何从 wasm 模块连接到本地 mongodb 实例?

我正在尝试使用编译为WebAssembly的Go将一些数据存储在我的本地MongoDB实例中。问题是,我什至无法连接到它。mondog实例不会以任何方式对来自wasm模块的连接使用react。只有从wasm模块连接时才会出现此问题。以普通方式编译时相同的代码工作正常,以及来自mongoshell的连接。运行的mongod实例没有密码保护。如果重要的话,我的操作系统是Windows10。我尝试将mongodbind_ip参数从localhost更改为我机器的实际本地地址,并使用不同的浏览器(Chrome75.0.3770.80,Opera60.0.3255.109)。更改超时持续时间也无

mongodb - go.mongodb.org/mongo-driver - InsertOne with NilValueObjectId

我有以下结构typeAccountstruct{IDprimitive.ObjectID`json:"id"bson:"_id"`Emailstring`json:"email"`Passwordstring`json:"password"`}和下面的函数func(a*Account)Create()map[string]interface{}{ifresp,ok:=a.Validate();!ok{returnresp}hashedPassword,_:=bcrypt.GenerateFromPassword([]byte(a.Password),bcrypt.DefaultCost